<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <meta name="renderer" content="webkit" />
        <meta name="format-detection" content="email=no" />
        <meta name="format-detection" content="telephone=no" />
        <meta http-equiv="Cache-Control" content="no-siteapp" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, shrink-to-fit=no, viewport-fit=cover">
        <?php if ($this->options->Favicon()) : ?>
        <link rel="shortcut icon" href="<?php $this->options->Favicon() ?>" />
        <?php else : ?>
        <link rel="shortcut icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text x=%22-0.125em%22 y=%22.9em%22 font-size=%2290%22>🌈</text></svg>" />
        <?php endif; ?>
        <title><?php $this->archiveTitle(array('category' => '分类 %s 下的文章', 'search' => '包含关键字 %s 的文章', 'tag' => '标签 %s 下的文章', 'author' => '%s 发布的文章'), '', ' - '); ?><?php $this->options->title(); ?></title>
        <?php if ($this->is('single')) : ?>
          <meta name="keywords" content="<?php echo (isset($this->fields->keywords) && $this->fields->keywords) ? $this->fields->keywords : htmlspecialchars($this->_keywords ?? '', ENT_QUOTES, 'UTF-8'); ?>" />
          <meta name="description" content="<?php echo (isset($this->fields->description) && $this->fields->description) ? $this->fields->description : htmlspecialchars($this->_description ?? '', ENT_QUOTES, 'UTF-8'); ?>" />
          <?php $this->header('keywords=&description='); ?>
        <?php else : ?>
          <?php $this->header(); ?>
        <?php endif; ?>
        <?php
            $fontUrl = $this->options->CustomFont ?? ''; // 使用空字符串作为默认值
            $fontFormat = '';
            
            if (strpos($fontUrl, 'woff2') !== false) {
                $fontFormat = 'woff2';
            } elseif (strpos($fontUrl, 'woff') !== false) {
                $fontFormat = 'woff';
            } elseif (strpos($fontUrl, 'ttf') !== false) {
                $fontFormat = 'truetype';
            } elseif (strpos($fontUrl, 'eot') !== false) {
                $fontFormat = 'embedded-opentype';
            } elseif (strpos($fontUrl, 'svg') !== false) {
                $fontFormat = 'svg';
            }
        ?>
        <style>
            @font-face {
                font-family: 'wodeziti';
                font-weight: 400;
                font-style: normal;
                font-display: swap;
                src: url('<?php echo $fontUrl ?>');
                <?php if ($fontFormat) : ?>src: url('<?php echo $fontUrl ?>') format('<?php echo $fontFormat ?>');
                <?php endif; ?>
            }
            body {
                <?php if ($fontUrl) : ?>
                font-family: 'wodeziti';
                font-weight: 400;
                <?php else : ?>
                font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
                <?php endif; ?>
            }
            <?php $this->fields->css();?>
        </style>

        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
        <link rel="stylesheet" href="<?php _getAssets('assets/css/main.css'); ?>">
        <link rel="stylesheet" href="<?php _getAssets('assets/css/page.css'); ?>">
    </head>
    
    <body class="<?php 
    if ($this->is('index')) : // 判断首页
        echo 'home-page';
    elseif ($this->is('single')) : // 判断为阅读页面(page/post)
        echo 'single-page';
    elseif ($this->is('category')) : // 判断为分类页面
        echo 'category-page';
    endif; 
?>">
        
        
        <nav class="hero-nav">
            
            <section class="mobile-section">
                <button class="mobile-nav-toggle" aria-label="菜单">
                    <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-layout-panel-left-icon lucide-layout-panel-left"><rect width="7" height="18" x="3" y="3" rx="1"/><rect width="7" height="7" x="14" y="3" rx="1"/><rect width="7" height="7" x="14" y="14" rx="1"/></svg>
                </button>
            </section>
            
            <a class="nav-button" id="site-name" href="/">
                <i class="site-logo"><?php $this->options->title() ?></i>
                <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-house-plug-icon lucide-house-plug"><path d="M10 12V8.964"/><path d="M14 12V8.964"/><path d="M15 12a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2v-2a1 1 0 0 1 1-1z"/><path d="M8.5 21H5a2 2 0 0 1-2-2v-9a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2h-5a2 2 0 0 1-2-2v-2"/></svg>
            </a>
            <div class="nav-category-wrapper">
                <li class="nav-category-container">
                    <div class="category-trigger" id="<?php $this->options->custom_category_name();?>"></div>
                    <ul class="header-main-nav category-dropdown">
                        <?php $this->widget('Widget_Metas_Category_List')->to($category); ?>
                        <?php while($category->next()): ?>
                        <li>
                            <a href="<?php $category->permalink(); ?>" title="<?php $category->name(); ?>"><?php $category->name(); ?></a>
                        </li>
                        <?php endwhile; ?>
                    </ul>
                </li>
                <li class="nav-category-container">
                    <div class="category-trigger" id="<?php $this->options->custom_page_name();?>"></div>
                    <ul class="header-main-nav category-dropdown">
                        <?php $this->widget('Widget_Contents_Page_List')->to($pages); ?>
                        <?php while($pages->next()): ?>
                        <li>
                            <a<?php if($this->is('page', $pages->slug)): ?> class="current"<?php endif; ?> href="<?php $pages->permalink(); ?>" title="<?php $pages->title(); ?>"><?php $pages->title(); ?></a>
                        </li>
                        <?php endwhile; ?>
                    </ul>
                </li>
            </div>
        </nav>